include $(TOPDIR)/rules.mk

PKG_NAME:=keevi.vnstat
PKG_VERSION:=1.0.1
PKG_RELEASE:=2

include $(INCLUDE_DIR)/package.mk

define Package/keevi.vnstat
  SECTION:=net
  CATEGORY:=Network
  TITLE:=vnstat addon for keevi
  DEPENDS:=+keevi +vnstat
endef

define Package/keevi.vnstat/description
  vnstat web interface for keevi router web interface integration framework
endef

define Build/Prepare
endef

define Build/Compile
endef

define Package/keevi.vnstat/install	
	$(CP) -r src/* $(1)
endef

define Package/keevi.vnstat/postinst
#!/bin/sh

MOUNT="/media/DISK_A1/system"
export PATH=$$MOUNT/bin:$$MOUNT/sbin:$$MOUNT/usr/bin:$$MOUNT/usr/sbin:/sbin:/usr/sbin:/bin:/usr/bin
export LD_LIBRARY_PATH=$$MOUNT/lib:$$MOUNT/usr/lib:/lib:/usr/lib

. /bin/iface-names.sh
vnstat -u -i $$BOARD_INTERFACE_WAN > /dev/null 2>&1
vnstat -u -i $$BOARD_INTERFACE_LAN > /dev/null 2>&1

if [ -f $$MOUNT/etc/init.d/K12vnstatd ]
then
    mv $$MOUNT/etc/init.d/K12vnstatd $$MOUNT/etc/init.d/S12vnstatd
fi
$$MOUNT/etc/init.d/S12vnstatd start
update_sidebar.lua
endef

define Package/keevi.vnstat/postrm
#!/bin/sh

MOUNT="/media/DISK_A1/system"
export PATH=$$MOUNT/bin:$$MOUNT/sbin:$$MOUNT/usr/bin:$$MOUNT/usr/sbin:/sbin:/usr/sbin:/bin:/usr/bin
export LD_LIBRARY_PATH=$$MOUNT/lib:$$MOUNT/usr/lib:/lib:/usr/lib

update_sidebar.lua
endef

$(eval $(call BuildPackage,keevi.vnstat))
